<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>众秀众筹</title>
	<meta name="Keywords" content="众筹，众筹网，众筹导航，众筹门户，股权众筹，众筹平台，众筹圈子人，众筹项目，众筹三方
影视众筹，店铺众筹，餐饮众筹，众筹报告，创业众筹，投后管理，项目融资，项目众筹，权力的游戏，冰与火之歌" />
	<meta name="Description" content="汇集各行业高手分析众筹项目，行业问答，众筹资讯。" />
	<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
	<meta name="renderer" content="webkit"/>
	<link rel="stylesheet" href="<%=path%>/css/bootstrap/3.3.5/css/bootstrap.min.css" />
	<link rel="stylesheet" href="<%=path%>/js/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cropper.min.css" />
	<link rel="stylesheet" href="<%=path%>/css/cz.css" />

	<script src="<%=path%>/js/jquery-1.11.0.min.js"></script>
	<script src="<%=path%>/js/plugins/layer/layer.js"></script>
	<script src="<%=path%>/css/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script src="<%=path%>/js/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
	<script src="<%=path%>/js/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>

	<script src="<%=path%>/js/slider.js"></script>
	<script src="<%=path%>/js/cropper.min.js"></script>
	<script src="<%=path%>/js/common.js"></script>
	<script type="text/javascript" src="<%=path %>/js/plugins/ajaxfileupload.js"></script>
	
	<script type="text/javascript" src="<%=path %>/js/plugins/CityJson.js"></script>
    <script type="text/javascript" src="<%=path %>/js/plugins/ProJson.js" ></script>
    <script type="text/javascript">
        $(function () {
        	var city_value="${activity.activityCity}";
        	var province_value="${activity.activityProvince}";
            $.each(province, function (k, p) { 
                var option = "<option value='" + p.ProID + "' id='" + p.ProName + "'>" + p.ProName + "</option>";
                $("#selProvince").append(option);
            });
             
            $("#selProvince").change(function () {
            	provinceChange();
            });
            
            $("#selCity").change(function () {
            	$("#activity_city").val($(this).find("option:selected").text());
            });
            
            var activityType='${activity.activityType}';
            if(activityType=='1'){
            	$("#activityType_1").attr("checked",true);
            	selectType(1);
            }else{
            	$("#activityType_2").attr("checked",true);
            	selectType(2);
            }
                        
            $("#selProvince option[id='"+province_value+"']").attr("selected",true);
            provinceChange();
            $("#selCity option[id='"+city_value+"']").attr("selected",true);
            $("#activity_city").val($("#selCity").find("option:selected").text());
        });
        
        function provinceChange(){
        	var selValue = $("#selProvince").val();
            $("#selCity option:gt(0)").remove();
            $("#activity_city").val("");
            
            $.each(city, function (k, p) { 
                if (p.ProID == selValue) {
                    var option = "<option value='" + p.CityID + "' id='" + p.CityName + "'>" + p.CityName + "</option>";
                    $("#selCity").append(option);
                }
            });
            
            $("#activity_province").val($("#selProvince").find("option:selected").text());
        }
        
        function selectType(activity_type){
        	if(activity_type==1){
        		$("#activity_address_div").show();
        		
        		$("#activity_url_div").hide();
        		$("#activity_url").val("");
        	}else if(activity_type==2){
        		$("#activity_address_div").hide();
        		$("#activity_url_div").show();
        		$("#selProvince").val("");
        		$("#selCity").val("");
        		$("#activity_province").val("");
        		$("#activity_city").val("");
        	}
        }
    </script>
<body class="gray-bg">
<jsp:include page="/views/commons/header.jsp"></jsp:include>
<div class="container page-single">
	<div class="col-md-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">活动编辑</h3>
			</div>
			<div class="panel-body event-create">

				<form class="form-horizontal" id="activity_form" action="javascript:insertActivity()">
					<input type="hidden" name="activityId" value="${activity.activityId}">
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-1 control-label">
							活动名称 <em>*</em>
						</label>
						<div class="col-sm-10">
							<input class="form-control event-create-form-control-block" maxlength="100" minlength="1" name="activityName" placeholder="活动标题" type="text" value="${activity.activityName}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-1 control-label">
							主办方 <em>*</em>
						</label>
						<div class="col-sm-10">
							<input class="form-control " maxlength="100" name="activityOrganizers" placeholder="活动主办方" type="text" value="${activity.activityOrganizers}">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-1 control-label">
								活动类型 <em>*</em>
						</label>
						<div class="col-sm-10">
							<label class='checkbox-inline'>
								<input type="radio" name="activityType" id="activityType_1" value="1" onclick="javascript:selectType(1)">
								线下活动
							</label>
							<label class='checkbox-inline'>
								<input type="radio" name="activityType" id="activityType_2" value="2" onclick="javascript:selectType(2)">
								网上直播
							</label>
						</div>
					</div>
					
					<div class="form-group" id="activity_url_div">
						<label for="inputEmail3" class="col-sm-1 control-label">
							直播网址
						</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="activity_url" name="activityUrl"  value="${activity.activityUrl}" placeholder="直播网址">
						</div>
					</div>
					<div class="form-group" id="activity_address_div">
						<label for="inputEmail3" class="col-sm-1 control-label">
							活动地点
						</label>
						<div class="col-sm-2">
							<select id="selProvince">
						        <option value="">--请选择省份--</option>
						    </select>
						    <input type="hidden" id="activity_province" name="activityProvince" value="${activity.activityProvince}">
						</div>
						<div class="col-sm-2">
							<select id="selCity">
						        <option value="">--请选择城市--</option>
						    </select>
						    <input type="hidden" id="activity_city" name="activityCity" value="${activity.activityCity}">
						</div>
						<div class="col-sm-6">
							<input type="text" class="form-control" name="activityAddress"  value="${activity.activityAddress}" placeholder="例如：南山区科苑北25号">
						</div>
					</div>
					
					<div class="form-group" id="data_5">
						<label for="aa" class="col-sm-1 control-label">活动时间 <em>*</em></label>
						<div class="col-sm-5">
							<div id="datepicker" class="input-daterange input-group">
								<input type="text"  name="activityBeginTime"  value="<fmt:formatDate value='${activity.activityBeginTime}' pattern='yyyy-MM-dd HH:mm'/>" class="input-sm form-control form_datetime_1">
								<span class="input-group-addon">到</span>
								<input type="text"  name="activityEndTime"  value="<fmt:formatDate value='${activity.activityEndTime}' pattern='yyyy-MM-dd HH:mm'/>" class="input-sm form-control form_datetime_2">
							</div>
						</div>
					</div>
					<div class="form-group">
						<label for="aa" class="col-sm-1 control-label">上传海报 <em>*</em></label>
						<div class="col-sm-10">
							<div class="img-container">
								<img id="activity_picture_img" src="<%=path %>/uncheck/pictures/servlet?id=${activity.activityPicture}" width="240" height="160" alt="Picture">
							</div>
							<label class="btn btn-primary" for="activity_picture_file" title="上传图片">
								<input type="file" class="hide" id="activity_picture_file" name="file" accept="image/*" 
								onchange="javascript:uploadImage('activity_picture_img','activity_picture_file','activity_picture',2)">上传图片
							</label>
							<input type="hidden" id="activity_picture" name="activityPicture" value="${activity.activityPicture}">
						</div>
					</div>
					<div class="form-group">
						<label for="aa" class="col-sm-1 control-label">活动介绍 <em>*</em></label>
						<div class="col-sm-10">
							<textarea name="activityDetail" style="width:100%;height:400px;visibility:hidden;">
							<fns:encodes value="${activity.activityDetail}" type="4"/>
							</textarea>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-1 col-sm-10">
							<button type="submit" class="btn btn-primary">提交活动</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<jsp:include page="/views/commons/footer.jsp"></jsp:include>

<link rel="stylesheet" href="<%=path%>/js/plugins/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="<%=path%>/js/plugins/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="<%=path%>/js/plugins/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="activityDetail"]', {
				allowFileManager: false,
				allowUpload : true,
				uploadJson:"<%=path %>/uncheck/pictures/upload/json",
				items : [
				         'source', '|', 'undo', 'redo', '|', 'preview',  'template', 'cut', 'copy', 'paste',
				         'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				         'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				         'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				         'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				         'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 
				         'emoticons', 'baidumap', 'pagebreak','anchor', 'link', 'unlink', '|', 'about'
				 ]
			});
		});
		//$("#data_5 .input-daterange").datepicker({
		//	keyboardNavigation: !1,
		//	forceParse: !1,
		//	autoclose: !0
		//})
	})
	
	function insertActivity(){
		$("#activity_confirm_btn").addClass("disabled").attr("disabled","disabled").val("提交中");
		$.ajax({
			url : path + "/check/activity/update",
			type : "post",
			dataType : "json",
			data : $("#activity_form").serialize(),
			success : function(data)
			{
				if(data.result){
					layer.msg("发布成功",{icon: 1});
					window.location.href=path + "/views/activity/activity_list.jsp";
				}else{
					layer.msg(data.message,{icon: 2});
					$("#activity_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
				$("#activity_confirm_btn").removeClass("disabled").removeAttr("disabled").val("提交");
			}
		});
	}
	</script>
	<script type="text/javascript" th:inline="javascript">
    $(function() {
        $(".form_datetime_1").datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd hh:ii',

        });
        $(".form_datetime_2").datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd hh:ii',

        });
    });
</script>
</body>
</html>